package com.kelp.codetoolkit.enums

/**
 * @author: liuyuebai
 * @date: 2024/8/3 09:19
 * @description:
 */
enum class MySQLToJavaTypeEnum(val mType:String,val jFullType:String,val jShortType:String){
    NONE("none","none","none"),
    BIGINT("bigint","java.lang.Long","Long"),
    BOOLEAN("boolean","java.lang.Boolean","Boolean"),
    CHAR("char","java.lang.String","String"),
    DATE("date","java.time.LocalDate","LocalDate"),
    DATETIME("datetime","java.time.LocalDateTime","LocalDateTime"),
    DECIMAL("decimal","java.math.BigDecimal","BigDecimal"),
    ENUM("enum","java.lang.String","String"),
    INT("int","java.lang.Integer","Integer"),
    JSON("json","java.lang.String","String"),
    LONGTEXT("longtext","java.lang.String","String"),
    MEDIUMINT("mediumint","java.lang.Integer","Integer"),
    MEDIUMTEXT("mediumtext","java.lang.String","String"),
    NUMERIC("numeric","java.math.BigDecimal","BigDecimal"),
    SMALLINT("smallint","java.lang.Integer","Integer"),
    TEXT("text","java.lang.String","String"),
    TINYINT("tinyint","java.lang.Integer","Integer"),
    TINYTEXT("tinytext","java.lang.String","String"),
    VARCHAR("varchar","java.lang.String","String"),

    ;



   companion object{
       fun getJavaType(mType:String): MySQLToJavaTypeEnum {
           MySQLToJavaTypeEnum.values().forEach {it ->
               if (it.mType == mType) {
                   return it
               }
           }
           return NONE;
       }

       fun isNone(mType:String):Boolean{
           return NONE.mType == mType
       }

       fun getMySQLType(jFullType: String):MySQLToJavaTypeEnum{
           MySQLToJavaTypeEnum.values().forEach {it ->
               if (it.jFullType == jFullType) {
                   return it
               }
           }
           return NONE;
       }
   }
}